//二叉树所有路径
class Solution {
public:
    string path;
    vector<string> ret;
    vector<string> binaryTreePaths(TreeNode* root) {
        if(root == nullptr) return {};
        dfs(root, path);
        return ret;
    }
    void dfs(TreeNode *root, string path)
    {
        if(root->left == nullptr && root->right == nullptr)
        {
            path += to_string(root->val);
            ret.push_back(path);
            return;
        }
        else
        {
            path += to_string(root->val) + "->";
        }
        if(root->left != nullptr) dfs(root->left, path);
        if(root->right != nullptr) dfs(root->right, path);
    }
};